Skip to content

Conversation

@nick-livefront
Copy link
Contributor

@nick-livefront nick-livefront commented Jan 2, 2026

🎟️ Tracking

PM-24978
Clients PR: bitwarden/clients#17790

📔 Objective

Currently the SDK swallows any decryption errors for Attachments and thus hides all attachments from the user. Even when the user has multiple attachments on a cipher.

This adds a new attachment_decryption_failures attribute to CipherView that is populated with all attachments that fail to decrypt. This can then be consumed by clients to allow the user to delete any corrupted ciphers.

🚨 Breaking Changes

❓ This could be a breaking change for the mobile clients if they expect attachment decryptions to be ignored. I do not know if that is the case yet. I'll reach out.

No additional changes only.

Client UI

Screenshot 2025-12-02 at 2 36 42 PM

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed
    issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@nick-livefront nick-livefront requested review from a team as code owners January 2, 2026 22:21
@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2026

Logo
Checkmarx One – Scan Summary & Details404d8945-55c4-4f92-88ed-7062702a0c46

Great job! No new security vulnerabilities introduced in this pull request

@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2026

🔍 SDK Breaking Change Detection Results

SDK Version: vault/pm-24978/corrupt-attachments (40ac965)
Completed: 2026-01-19 18:10:36 UTC
Total Time: 248s

Client Status Details
typescript ✅ No breaking changes detected TypeScript compilation passed with new SDK version - View Details

Breaking change detection completed. View SDK workflow

@codecov
Copy link

codecov bot commented Jan 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.43%. Comparing base (23dbe0d) to head (40ac965).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #644      +/-   ##
==========================================
+ Coverage   79.35%   79.43%   +0.07%     
==========================================
  Files         293      293              
  Lines       32264    32387     +123     
==========================================
+ Hits        25603    25726     +123     
  Misses       6661     6661              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines 218 to 221
let (file_name, decryption_failure) = match self.file_name.decrypt(ctx, key) {
Ok(name) => (name, false),
Err(..) => (None, true),
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the SDK swallows any decryption errors for Attachments and thus hides all attachments from the user.

Where is the actual error being swallowed? I would suggest adding the handling logic there, maybe following the pattern of decrypt_list_with_failures. with the change here, you end up throwing away the CryptoError and the function returns as a "successful" decryption, breaking the contract of "This function returns a decrypted object, or an Err(CryptoError)"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error is being swallowed when the cipher list is being decrypted here.

maybe following the pattern of decrypt_list_with_failures

This could work but it would expand the API of the Cipher. I could leave the existing attachments alone and only return the decrypted attachments and then add a attachment_failure property. What do you think about that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added my approach here: 3d5dfac

I appreciate the feedback, let me know what you think!

Comment on lines +350 to +352
/// Attachments that failed to decrypt. Only present when there are decryption failures.
#[serde(skip_serializing_if = "Option::is_none")]
pub attachment_decryption_failures: Option<Vec<attachment::AttachmentView>>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Maybe move this to just below line 347?

attachments: &[Attachment],
ctx: &mut KeyStoreContext<KeyIds>,
key: SymmetricKeyId,
) -> (Option<Vec<AttachmentView>>, Option<Vec<AttachmentView>>) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Vec<AttachmentView>, Vec<AttachmentView>) might be a better choice here (foregoing wrapping them in Option) - an empty Vec conveys the same information and simplifies a lot of the downstream logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do like removing the Option as it cuts down on the needed code and mental thought. It doesn't match the definitions on the CipherView so I had to rewrap in Some but that feels like an okay trade off

ce23472

ciphers_key,
)
})
.unwrap_or((None, None));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional nit: .unwrap_or_default() has the same effect here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 ce23472

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants